<style lang="scss" scoped>
	.uni-textarea {
	  margin: 20upx 25upx;
	  padding: 20upx;
	  border-radius: 10upx;
	  border: 1upx solid #f2f2f2;
	  background-color: #f2f2f2;
	}
	.btns{
		width: 700upx;
		margin: 20upx 25upx;
	}
</style>

<template>
	<view class="report">
		<!-- 内容输入框 -->
		<view class="uni-textarea">
		  <textarea placeholder-style="color:#AAAAAA" placeholder="请输入举报原因" @input="bindTextAreaInput" />
		</view>
		<view class="btns">
		  <u-button type="primary" size="default" @click="sendReport" :disabled="sendStatus">举报</u-button>
		</view>
	</view>
</template>
	
<script>
	export default {
		data(){
			return {
				// 当前 feedID
				feedId: 0,
				// 输入域输入的内容
				reportVal: '',
				// 发送状态
				sendStatus:false
			}
		},
		onLoad(options){
			console.log(options.id)
			this.feedId = options.id;
		},
		methods:{
			// textarea 输入内容获取
			bindTextAreaInput(e) {
			  this.reportVal = e.detail.value;
			  console.log({
			  	id: this.feedId,
			  	reason: this.reportVal
			  })
			},
			// 发送举报内容
			async sendReport(){
				if(this.sendStatus) return ;
				this.sendStatus = true;
				console.log({
					id: this.feedId,
					reason: this.reportVal
				})
				await this.$u.api.reportThisFeed({
					id: this.feedId,
					reason: this.reportVal
				});
				this.sendStatus = false;
				uni.showToast({
				  title: "举报成功",
				  duration: 1500,
				  complete:()=>{
					  let timer = setTimeout(()=>{
						  clearTimeout(timer);
						  uni.navigateBack();
					  },1000)
				  }
				})
			}
		}
	}
</script>
